//
//  UIButton + EXtensions.swift
//  MXWeiBo
//
//  Created by Apple on 16/2/24.
//  Copyright © 2016年 Applea. All rights reserved.
//

import UIKit
extension UIButton {

    convenience init(title: String?,
        color: UIColor=UIColor.orangeColor(),
        imageName: String? = nil,
        backImageName:String? = nil){
    
        self.init()
        
        self.setTitle(title, forState: .Normal)
        self.setTitleColor(color, forState: .Normal)
            if let imageName = imageName{
                self.setImage(UIImage(named: imageName), forState: .Normal)
                self.setImage(UIImage(named: imageName+"_highlighted"), forState: .Highlighted)
            }

            if let backImageName = backImageName{
            self.setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
           self.setBackgroundImage(UIImage(named: backImageName+"_highlighted"), forState: .Highlighted)
            }
       
       sizeToFit()
    
    }
}
